﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace SilverlightMapCreator
{
    public class Utils
    {
        public IList<IList<T>> SplitList<T>(IList<T> listToSplit, Int32 countToTake)
        {
            IList<IList<T>> splitList = new
            List<IList<T>>();
            Int32 countToSkip = 0;
            do
            {
                splitList.Add(listToSplit.Skip(countToSkip)
                .Take(countToTake).ToList());
                countToSkip += countToTake;
            } while (countToSkip < listToSplit.Count);
            return splitList;
        }

        public static void Print(double[,] matrix)
        {
            var rows = matrix.GetLength(0);
            var columns = matrix.GetLength(1);
            StringBuilder builder = new StringBuilder();
            builder.Append("{");
            for (int i = 0; i < rows; i++)
            {
                builder.Append("{");
                for (int j = 0; j < columns; j++)
                {
                    builder.Append(matrix[i, j]);
                    if (j < columns - 1)
                    {
                        builder.Append(",");
                    }
                }
                builder.Append("}");
                if (i < rows - 1)
                {
                    builder.Append(",");
                }
            }
            builder.Append("}");
            Debug.WriteLine(builder.ToString());
        }
    }
}
